import AutomataBuilder

class DeterministicAutomata():

    def __init__(self, a):
        self.s = a.s
        self.states = a.states
        self.final = a.final
        self.delta = a.delta

    def parse(self, line):
        current_state = self.s
        for i in line:
            #print current_state
            if i=='\n':
                continue

#	    print "i->("+str(i)+")"
            if (current_state, i) in self.delta:
                current_state = self.delta[(current_state, i)]
            else:
                #print 'Aaaaaaaaaaaaaggh!'
                return False

        return current_state in self.final
